﻿@model XCode.Membership.User
@using System.Linq
@using System.Reflection
@using XCode
@using XCode.Configuration
@using NewLife.Cube.Entity;
@{
    var fact = EntityFactory.CreateFactory(ViewData.ModelMetadata.ModelType);
    var user = Model as IUser;
}
<div class="row">
    @await Html.PartialAsync("_User_Nav")
</div>
<div class="row">
    <label class="control-label hiddex-xs col-sm-2"></label>
    <div class="col-xs-12 col-sm-8">
        <div class="form-horizontal">
            @if (ViewBag.StatusMessage != null)
            {
                <div class="alert alert-success alert-dismissible text-center" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <strong>@ViewBag.StatusMessage</strong>
                </div>
            }
            @using (Html.BeginForm("Info", null, new { id = Model[fact.Unique.Name] }, FormMethod.Post, null, new { enctype = "multipart/form-data" }))
            {
                @Html.ValidationSummary()
                if (!user.Avatar.IsNullOrEmpty())
                {
                    <div class="form-group">
                        <label class="control-label col-xs-3 col-sm-3"></label>
                        <div class="input-group col-xs-9 col-sm-5">
                            <img src="@user.GetAvatarUrl()" style="max-width: 400px; max-height: 400px" />
                        </div>
                    </div>
                }
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">名称</label>
                    <div class="input-group col-xs-9 col-sm-5">
                        <input value="@user.Name" class="col-xs-12 col-sm-8 col-sm-6 col-lg-4" disabled="disabled" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">显示名</label>
                    <div class="input-group col-xs-9 col-sm-5">
                        @Html.ForEditor("DisplayName")
                        @Html.ForDescription("DisplayName")
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">性别</label>
                    <div class="input-group col-xs-9 col-sm-5">
                        @Html.ForEditor("Sex", user.Sex)
                        @Html.ForDescription("Sex")
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">邮件</label>
                    <div class="input-group col-xs-9 col-sm-5">
                        @Html.ForEditor("Mail")
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">手机</label>
                    <div class="input-group col-xs-9 col-sm-5">
                        @Html.ForEditor("Mobile")
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">代码</label>
                    <div class="input-group col-xs-9 col-sm-5">
                        @Html.ForEditor("Code")
                    </div>
                    <span class="hidden-xs col-sm-4">
                        <span class="middle">@Html.ForDescription("Code")</span>
                    </span>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">生日</label>
                    <div class="input-group col-xs-9 col-sm-5">
                        @Html.ForEditor("Birthday")
                    </div>
                    <span class="hidden-xs col-sm-4">
                        <span class="middle">@Html.ForDescription("Birthday")</span>
                    </span>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">角色</label>
                    <div class="input-group col-xs-9 col-sm-5">
                        @(user.Roles.Join(",", r => r + ""))
                    </div>
                    <span class="hidden-xs col-sm-4">
                        <span class="middle">主要角色与次要角色</span>
                    </span>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">部门</label>
                    <div class="input-group col-xs-9 col-sm-5">
                        @((user as User).DepartmentName)
                    </div>
                    <span class="hidden-xs col-sm-4">
                        <span class="middle">@Html.ForDescription("Department")</span>
                    </span>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">头像</label>
                    <div class="input-group col-sm-2">
                        <label class="">@user.Avatar</label> &nbsp;
                        <input accept="image/*" id="Avatar" name="Avatar" type="file" />
                    </div>

                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">登录次数</label>
                    <div class="input-group col-sm-2">
                        @user.Logins
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">最后登录</label>
                    <div class="input-group col-sm-2">
                        @user.LastLogin.ToFullString("")
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">最后登录IP</label>
                    <div class="input-group col-xs-9 col-sm-5">
                        @user.LastLoginIP
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3 col-sm-3">备注</label>
                    <div class="input-group col-xs-9 col-sm-5">
                        @Html.ForEditor("Remark")
                    </div>
                </div>
                <div class="clearfix form-actions">
                    <label class="control-label col-sm-4"></label>
                    <button type="submit" class="btn btn-success btn-sm"><i class="glyphicon glyphicon-save"></i><strong>保存</strong></button>
                    <button type="button" class="btn btn-danger btn-sm" onclick="history.go(-1);"><i class="glyphicon glyphicon-remove"></i><strong>取消</strong></button>
                </div>
            }
        </div>
    </div>
</div>